发起GET
请求,函数原型:
function Swoole\Coroutine\Http\Client->get(string $path);
- $path 设置URL路径,如
/index.html
,注意这里不能传入http://domain
- 使用get会忽略
setMethod
设置的请求方法,强制使用GET
$cli = new Swoole\Coroutine\Http\Client('127.0.0.1', 80);
$cli->setHeaders([
'Host' => "localhost",
"User-Agent" => 'Chrome/49.0.2587.3',
'Accept' => 'text/html,application/xhtml+xml,application/xml',
'Accept-Encoding' => 'gzip',
]);
$cli->get('/index.php');
echo $cli->body;
$cli->close();